package org.jwxa.jwxa4j.nodes;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 节点抽象类
 * @author janjan, xujian_jason@163.com
 *
 */
public abstract class AbstractWXNode implements WXNode {

	// 节点名称
	protected String nodeName;
	// 子节点
	protected List<WXNode> childs;
	// 节点类型
	protected String nodeType;
	
	protected AbstractWXNode(String nodeName) {
		this.nodeName = nodeName;
		this.childs = new ArrayList<WXNode>();
	}
	
	@Override
	public String getNodeName() {
		return this.nodeName;
	}
	
	public List<WXNode> getChilds() {
		return Collections.unmodifiableList(childs);
	}
	
	public AbstractWXNode addChild(WXNode child) {
		if(child != null) {
			childs.add(child);
		}
		return this;
	}

	public String getNodeType() {
		return nodeType;
	}

	public void setNodeType(String nodeType) {
		this.nodeType = nodeType;
	}
	
}
